package cn.pink.gamesrv.msg;

import cn.pink.common.support.MsgRoute;
import cn.pink.core.support.Param;
import cn.pink.core.support.observer.MsgSubject;
import cn.pink.gamesrv.account.AccountMsgHandler;
import com.google.protobuf.GeneratedMessageV3;

/**
 * 账号模块消息路由
 * @Author: pink
 * @Date: 2022/6/30 18:55
 */
public class AccountMsgRoute extends MsgRoute {
    @Override
    public void route(GeneratedMessageV3 msg, Param param) {
        int msgId = param.getInt("msgId");

        // 忽略不是本阶段要关心的协议
        if (!AccountMsgHandler.protos.contains(msgId)) {
            return;
        }

        MsgParamAccount mp = new MsgParamAccount(msg);
        mp.setSessionPoint(param.get("sessionPoint"));
        mp.setService(param.get("serv"));

        MsgSubject.fire(msgId, mp);
    }
}
